package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitorInterface;

public class EXPR2AFactory extends AbstractTokenVisitorFactory {

	private static EXPR2AFactory INSTANCE;
	
	private EXPR2A1Factory expr2a1Factory ;
	private LambdaFactory lambdaFactory;
	
	public static EXPR2AFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new EXPR2AFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			expr2a1Factory = EXPR2A1Factory.getInstance();
			lambdaFactory = LambdaFactory.getInstance();
		}
	};
	
	
	private EXPR2AFactory() throws Exception {
	}
	
	@Override
	public TokenVisitorInterface makeChainedVisitor(
			final TokenVisitorInterface siguiente) throws Exception {
		initializer.init();

		return expr2a1Factory.makeChainedVisitor(lambdaFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitorInterface makeVisitor() throws Exception {
		initializer.init();

		return expr2a1Factory.makeChainedVisitor(lambdaFactory.makeVisitor());
	}
	
	
}
